<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>操作竞拍车辆</title> 
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body>
	<div class="Wrapper">
		<form id="aucCarInfoForm">
			<div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
				<div class="fieldBox col_50">
					<div class="label">标题</div>
					<div class="field">
						<input name="prdNm" id="prdNm" type="text" class="ui-textbox"
							value="" validate="{required:true,maxlength:100}"> <span
							class="requiredSymbol">*</span>
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">支付表编号</div>
					<div class="field">
						<input name="paySchNo" id="paySchNo" type="text" class="ui-textbox"
							value="" validate="{required:true,maxlength:30}"> <span
							class="requiredSymbol">*</span>
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">发动机号</div>
					<div class="field">
						<input name="engNo" id="engNo" type="text" class="ui-textbox"
							value="" validate="{required:true,maxlength:40}"> <span
							class="requiredSymbol">*</span>
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">车架号</div>
					<div class="field">
						<input name="vin" id="vin" type="text" class="ui-textbox"
							value="" validate="{required:true,maxlength:30}"> <span
							class="requiredSymbol">*</span>
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">车牌号</div>
					<div class="field">
						<input name="carLicNo" id="carLicNo" type="text" class="ui-textbox"
							value="" validate="{required:true,maxlength:20}"> <span
							class="requiredSymbol">*</span>
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">是否售出</div>
					  <div class="field">
                      <select name="isSeld" id="isSeld" data-value="0" >
						<c:forEach items="${yNList }" var="kv" begin="0" step="1" varStatus="status">
								<option value="${kv.key }" >${kv.value }</option>
						</c:forEach>
                      </select>
                      <!-- <span class="requiredSymbol">*</span> -->
                 	</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">竞拍开始时间</div>
					<div class="field">
						<input name="stValidDt" id="stValidDt" type="text"  class="ui-datepicker" ligerui="{showTime:true}" value="" >
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">竞拍结束时间</div>
					<div class="field">
						<input name="endValidDt" id="endValidDt" type="text"  class="ui-datepicker" ligerui="{showTime:true}" value="" >
					</div>
				</div>
				<!-- 标准区域 -->
                <jsp:include page="../../system/sysRegion/sysStdRegionLvlSec.jsp" flush="true" >
					<jsp:param name="sysStdRegionDefShowLvl" value="2"/>
					<jsp:param name="sysStdRegionProvCdNm" value="省份"/>
					<jsp:param name="sysStdRegionCityCdNm" value="城市"/>
				</jsp:include>
				<div class="fieldset1 tabel_col tabel_col_s clearFix">
	                         <c:if test="${detailFlag!=true }"> 	       
			           	 <div class="fieldBox col_100" id="fileDetail">
			                    <div class="label">资料上传</div>
			                    <div class="field">
			                    	<jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload.jsp" flush="true" >
			                    		<jsp:param name="filePath" value="aucCarInfo"/>
			                    	</jsp:include>
			                    	<input name="licId" id="licId" type="hidden" value="${id}">
			                    </div>
			               </div>
			               </c:if>
			               
			               	 <c:if test="${detailFlag==true }">
						       <div class="fieldBox col_100" id="fileModify">
				                    <div class="label">资料</div>
				                    <div class="field">
				                    	<jsp:include page="../../system/sysUlFilesRec/sysUlFileRecListDetail.jsp" flush="true" >
				                    		<jsp:param name="pkId" value="${id}"/>
				                    		<jsp:param name="tabNm" value="AUC_CAR_INFO"/>
				                    	</jsp:include>
				                    </div>
				                </div>  
			               	 </c:if>
			         <c:if test="${detailFlag!=true }"> 	 
	                   <div class="fieldBox col_100" id="fileModify">
	                    <div class="label">资料</div>
	                    <div class="field">
	                    	<jsp:include page="../../system/sysUlFilesRec/sysUlFileRecList.jsp" flush="true" >
	                    		<jsp:param name="pkId" value="${id}"/>
	                    		<jsp:param name="tabNm" value="AUC_CAR_INFO"/>
	                    	</jsp:include>
	                    </div>
	                </div>  
	                </c:if>
	                
	               </div>
				<!-- hide data -->
				<div class="fieldBox col_100" style="display: none;">
					<div class="field">
						<input name="aid" id="aid" type="text" class="ui-textbox"
							value="${id}">
					</div>
				</div>
			</div>
		</form>
	</div>
	<script type="text/javascript">
	var detailFlag = '${detailFlag}';
	
	$(function() {
		initForm();
	   	initEvent();
	    initData();
	});
		
		//初始化表单
		function initForm(){
			$("#aucCarInfoForm").ligerForm({
                validate: true
           });
		}
		
		//初始化事件
		function initEvent(){
			
		}
		
		frameElement.dialog.onOk = function () {
			save();
		}
		frameElement.dialog.onCancel = function () {
			frameElement.dialog.close();
		}
		
		//保存
		function save(){
			var ligerForm = liger.get("aucCarInfoForm");
            if (!ligerForm.valid()) {
            	UIUtils.alertWarning(LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO);
                return false; //验证不通过，不执行以下代码
            }
            var data = ligerForm.getData();
            var fileParams = getUploadResultParams();//获取附件上传的信息
    	    data["fileParams"] = JSON.stringify(fileParams);
    	    data["id"] = $("#aid").val();
            var url = '<%=path%>/auccar/aucCarInfo/addOrModify.do';
            AjaxUtils.ajaxGet(url, data, saveCallback, true);
		}
		
		//回调
		function saveCallback(msg){
			 if(msg.success == 1){
				 UIUtils.alertSuccess(msg.info);
				 parent.audCarInfoGrid.reload();
				 frameElement.dialog.close();
			 }else{
				 UIUtils.alertError(msg.info);
			 }
		}

		
		//初始化数据
		function initData(){
			var _id = $("#aid").val();
	    	if(!_id)return;
	    	var _url = '<%=path%>/auccar/aucCarInfo/getById.do';
			AjaxUtils.ajaxGet(_url, {
				id : _id
			}, initCallback, true);
		}

		//初始化回调
		function initCallback(msg) {
			if(detailFlag == "true"){
				if(liger.get("prdNm")){
					liger.get("prdNm").setDisabled(true);
				}
				if(liger.get("paySchNo")){
					liger.get("paySchNo").setDisabled(true);
				}
				if(liger.get("engNo")){
					liger.get("engNo").setDisabled(true);
				}
				if(liger.get("vin")){
					liger.get("vin").setDisabled(true);
				}
				if(liger.get("carLicNo")){
					liger.get("carLicNo").setDisabled(true);
				}
				if(liger.get("isSeld")){
					liger.get("isSeld").setDisabled(true);
				}
				if(liger.get("stValidDt")){
					liger.get("stValidDt").setDisabled(true);
				}
				if(liger.get("endValidDt")){
					liger.get("endValidDt").setDisabled(true);
				}
				if(liger.get("regStdCityCd")){
					liger.get("regStdCityCd").setDisabled(true);
				}
				if(liger.get("regStdProvCd")){
					liger.get("regStdProvCd").setDisabled(true);
				}
			}
			if (msg.success == 1) {
				setData(msg.data);//设置数据
			} else {
				UIUtils.alertError(msg.info);
			}
		}

		//设置页面数据
		function setData(data) {
			var form = new liger.get("aucCarInfoForm");
			form.setData({
				aid : data.id,
				prdNm : data.prdNm,
				paySchNo : data.paySchNo,
				engNo : data.engNo,
				vin : data.vin,
				carLicNo : data.carLicNo,
				isSeld : data.isSeld,
				stValidDt : data.stValidDt,
				endValidDt : data.endValidDt,
				regStdCityCd : data.rgnCyCd,
				regStdProvCd : data.rgnPrCd
			});
			
			//设置回显标准省市县
			setSysStdProvCdUpdateValue(data.rgnPrCd);//省
			setSysStdCityCdUpdateValue(data.rgnCyCd);//市
			//设置完回显值执行省市县变更事件
			setSysStdProvCdChange();
			setSysStdCityCdChange();
		};
	</script>
</body>
</html>